package com.wangsd.web.sys.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.*;
import java.util.Date;
import java.util.List;

/**
 * 菜单表
 */

@Data
@Entity
@Table(name = "sys_menu")
@ApiModel(value = "菜单表", description = "菜单表")
public class SysMenu {

    @ApiModelProperty(value = "id")
    @Id
    /*mybatis plus 自增主键*/
    @TableId(type = IdType.AUTO)
    /*jpa 生成自增策略*/
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(fill = FieldFill.INSERT)
    private Date createdTime;

    @ApiModelProperty(value = "修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date updatedTime;

    @ApiModelProperty(value = "（逻辑删除）是否已删；0，未删，1，已删")
    @TableField(fill = FieldFill.INSERT)
    private Integer deleted;

    @ApiModelProperty(value = "菜单名称")
    private String name;

    @ApiModelProperty(value = "菜单路径")
    private String path;

    @ApiModelProperty(value = "权限唯一键")
    @Column(name = "key_sign")
    private String keySign;

    @ApiModelProperty(value = "菜单图标")
    private String icon;

    @ApiModelProperty(value = "component")
    private String component;

    @ApiModelProperty(value = "父菜单id")
    private Long pid;

    @ApiModelProperty(value = "模块id")
    private Long applicationId;

    @ApiModelProperty(value = "排序字段")
    private Integer sort = 1000;


    @Transient
    @TableField(exist = false)
    @ApiModelProperty(value = "扩展子菜单")
    private List<SysMenu> children;

    @Transient
    @TableField(exist = false)
    @ApiModelProperty(value = "按钮权限集合")
    private List<String> actions;

    @Transient
    @TableField(exist = false)
    @ApiModelProperty(value = "按钮集合")
    private List<SysButton> buttonList;
}
